<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <style>
        ul {
            list-style: none;
        }
    </style>
</head>

<body>
    <ul>
        <li><input type="checkbox" name="like">看电影</li>
        <li><input type="checkbox" name="like">跳舞</li>
        <li><input type="checkbox" name="like">爬山</li>
        <li><input type="checkbox" name="like">打游戏</li>
        <li><input type="checkbox" name="like">运动</li>
        <li><input type="checkbox" name="like">绘画</li>
    </ul>
    <button onclick="select(true)">全选</button>
    <button onclick="select(false)">不选</button>
    <button>反选</button>

    <script type="text/javascript">
        var like = document.getElementsByName('like')
        var btns = document.querySelectorAll('button')
        function select(bool) {
            for (var i = 0; i < like.length; i++) {
                like[i].checked = bool
            }
        }

        btns[2].onclick = function () {
            for (var i = 0; i < like.length; i++) {
                if (like[i].checked == true) {
                    like[i].checked = false
                } else {
                    like[i].checked = true
                }
            }
        }
    </script>
</body>

</html>